package fr.upmc.cie.data;

import java.io.Serializable;

import android.content.ContentValues;

public class TicketItem implements Serializable, Comparable<TicketItem>{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private long id;
	private String title="";
	private String source="";
	private String date="";
	private String author="";
	private String link="";
	private String content="";
	private boolean isReaded;
	private float rating;
	
	public TicketItem() {}
	
	public TicketItem(TicketItem item){
		title = item.getTitle();
		source = item.getSource();
		date = item.getDate();
		author = item.getAuthor();
		link = item.getLink();
		content = item.getContent();
	}
	
	public void setTitle(String title) {
		this.title = title;
	}
	
	public String getTitle() {
		return title;
	}
	
	public void setSource(String source) {
		this.source = source;
	}
	
	public String getSource() {
		return source;
	}

	public void setLink(String link) {
		this.link = link;
	}

	public String getLink() {
		return link;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getContent() {
		return content;
	}

	public void setRating(float rating) {
		this.rating = rating;
	}

	public float getRating() {
		return rating;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public String getDate() {
		return date;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getAuthor() {
		return author;
	}

	public void setReaded(boolean isReaded) {
		this.isReaded = isReaded;
	}

	public boolean isReaded() {
		return isReaded;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getId() {
		return id;
	}
	
	public ContentValues getContentValues(){
		ContentValues cv = new ContentValues();
		cv.put("title",title);
		cv.put("source",source);
		cv.put("date", date);
		cv.put("author", author);
		cv.put("link", link);
		cv.put("content", content);
		cv.put("isReaded", isReaded);
		cv.put("rating", rating);
		return cv;
	}
	
	public String toString(){
		return this.title;
	}

	@Override
	public int compareTo(TicketItem another) {
		return this.getDate().compareTo(another.getDate());
	}
	
	public boolean equals(Object o){
		return this.getTitle().equals(((TicketItem) o).getTitle())&&this.getDate().equals(((TicketItem) o).getDate());
	}
}
